<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<label for="high">身高</label>
		<input type="text" placeholder="请输入身高" id="high" >
		<br>
		<br>
		<label for="weight">体重</label>
		<input type="text" placeholder="请输入体重" id="weight">
		<br>
		<br>
		<button onclick="btnClick()">点击查看您的BMI</button>
	</body>
	<script>
		function btnClick()
		{
			var input1 = document.getElementById("high");
			var input2 = document.getElementById("weight");
			var shengao = input1.value / 100;
			var tizhong = input2.value / 2;
			var res = tizhong / shengao /shengao;
			res = res.toFixed(2);
			if(res <= 18.4)
			{
				alert("BMI = "+ res + " " + "偏瘦");
			}
			else if(res >= 18.5 && res <=23.9)
			{
				alert("BMI = "+ res + " " + "正常");
			}
			else if(res >= 24.0 && res <=27.9)
			{
				alert("BMI = "+ res + " " + "偏重");
			}else
			{
				alert("BMI = "+ res + " " + "肥胖");
			}
		}
	</script>
</html>
